//
//  MCNewActivityViewController.m
//  TLYL
//
//  Created by miaocai on 2017/11/22.
//  Copyright © 2017年 TLYL01. All rights reserved.
//

#import "MCNewActivityViewController.h"
#import "MCNewActivityTableViewCell.h"
#import "MCNewActivityDetailViewController.h"
#import "MCNewActivityDetailTwoViewController.h"
#import "MCTNewActivityhdViewController.h"
#import "MCNewAcWuYue02ViewController.h"
#import "MCNewAcWuYueViewController.h"
#import "MCSharePoolModel.h"
#import "MCGongXiangViewController.h"

@interface MCNewActivityViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) MCSharePoolModel *sharePoolModel;
@property (nonatomic,assign) int count;
@property (nonatomic,strong) UITableView *tab;
@end

@implementation MCNewActivityViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    self.navigationItem.title = @"优惠活动";
    self.view.backgroundColor = RGB(231, 231, 231);
    [self setUpUI];
    
    [BKIndicationView showInView:self.view];
    MCSharePoolModel *sharePoolModel = [[MCSharePoolModel alloc] init];
    self.sharePoolModel = sharePoolModel;
    [sharePoolModel refreashDataAndShow];
    __weak __typeof(self)wself = self;
    sharePoolModel.callBackSuccessBlock = ^(ApiBaseManager *manager) {
        [BKIndicationView dismiss];
        bool IsShow = YES;
        if (manager.ResponseRawData) {
            IsShow = [manager.ResponseRawData[@"IsShow"] intValue];
        }
        
        if (IsShow) {
            self.count = 3;
        } else {
            self.count = 2;
        }
        [wself.tab reloadData];
    };
    
    sharePoolModel.callBackFailedBlock = ^(id manager, NSDictionary *errorCode) {
        [BKIndicationView dismiss];
    };
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden=NO;
    self.navigationController.navigationBar.translucent = NO;
}

#pragma mark -- setUpUI
-(void)setUpUI{
        self.automaticallyAdjustsScrollViewInsets = NO;
        UITableView *tab = [[UITableView alloc] initWithFrame:CGRectMake(MC_REALVALUE(13), MC_REALVALUE(3), G_SCREENWIDTH - MC_REALVALUE(26), G_SCREENHEIGHT - MC_REALVALUE(13)) style:UITableViewStylePlain];
        [self.view addSubview:tab];
        tab.backgroundColor = RGB(231, 231, 231);
        tab.separatorStyle = UITableViewCellSeparatorStyleNone;
        [tab registerNib:[UINib nibWithNibName:@"MCNewActivityTableViewCell" bundle:nil] forCellReuseIdentifier:@"cell"];
        tab.delegate = self;
        tab.dataSource = self;
        tab.rowHeight = 140;
        _tab=tab;
}

#pragma mark -- tableView delegate datasource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    MCNewActivityTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (indexPath.row == 2) {
//        cell.imgV.image = [UIImage imageNamed:@"gongxiangtu"];
//        cell.coverView.hidden = YES;
    }else if (indexPath.row == 0) {
        cell.imgV.image = [UIImage imageNamed:@"开业送.jpg"];
        cell.coverView.hidden = NO;
    }else if(indexPath.row == 1){
        cell.imgV.image = [UIImage imageNamed:@"争霸赛.jpg"];
        cell.coverView.hidden = NO;
    }else{
//        cell.imgV.image = [UIImage imageNamed:@"AGHuodong"];
//        cell.coverView.hidden = YES;
        
    }
   
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 1) {
        MCNewAcWuYueViewController *vc = [[MCNewAcWuYueViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];


    } else if (indexPath.row == 0) {
        MCNewAcWuYue02ViewController *vc = [[MCNewAcWuYue02ViewController alloc] init];
        [self.navigationController pushViewController:vc animated:YES];

    }else if(indexPath.row == 2){
        
//        MCGongXiangViewController *vc = [[MCGongXiangViewController alloc] init];
//        [self.navigationController pushViewController:vc animated:YES];

        
    }
    
}
@end
